package com.bwie.house.controller;

import java.util.Arrays;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bwie.house.entity.BrokerEntity;
import com.bwie.house.service.BrokerService;
import com.bwie.common.utils.PageUtils;
import com.bwie.common.utils.R;



/**
 * 
 *
 * @author wangguohai
 * @email 270901876@qq.com
 * @date 2022-04-21 20:35:03
 */
@RestController
@RequestMapping("house/broker")
public class BrokerController {
    @Autowired
    private BrokerService brokerService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = brokerService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{brokerId}")
    public R info(@PathVariable("brokerId") Integer brokerId){
		BrokerEntity broker = brokerService.getById(brokerId);

        return R.ok().put("broker", broker);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BrokerEntity broker){
		brokerService.save(broker);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BrokerEntity broker){
		brokerService.updateById(broker);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] brokerIds){
		brokerService.removeByIds(Arrays.asList(brokerIds));

        return R.ok();
    }

    @RequestMapping("/del/{id}")
    public R del(@PathVariable("id")Integer id){
        brokerService.removeById(id);

        return R.ok();
    }

}
